import request from '@/utils/request2'
import qs from 'qs'

/**
 * 表单分类
 */
export function getTypesByKey() {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/a1bpmn/sys/sysType/v1/form/getTypesByKey',
    method: 'get'
  })
}
export function getBusinessTableListJson(data) {
  return request({

    url: '/form/bus/businessTable/listJson',
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: qs.stringify(data)
  })
}
export function getFormModelTableListJson(data) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/form/design/models/listJson',
    method: 'POST',
    data: qs.stringify(data)
  })
}
export function getFormModelTableListAllJson(data) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/form/design/models/listAll',
    method: 'POST',
    data: qs.stringify(data)
  })
}
export function getFormModelById(id) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/form/design/models/id/'+id,
    method: 'GET'
  })
}
export function formUpdateMain(id) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/form/design/models/updateMain?modelId=' + id,
    method: 'POST'
  })
}
export function formRemove(id) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/form/design/remove/' + id,
    method: 'GET'
  })
}
export function businessTableSave(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/bus/businessTable/save',
    method: 'POST',
    data: JSON.stringify(data)
  })
}
export function businessObjectSave(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/bus/businessObject/save',
    method: 'POST',
    data: JSON.stringify(data)
  })
}
export function businessObjectDel(id) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/bus/businessObject/delete/' + id,
    method: 'GET'
  })
}
/**
 * 删除
 * @param data
 */
export function removeBusinessObject(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/bus/businessObject/remove',
    method: 'POST',
    data: data
  })
}
export function removeBusinessObjectEs(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/bus/businessObject/es',
    method: 'POST',
    data: data
  })
}

export function businessTableDel(id) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/bus/businessTable/delete/' + id,
    method: 'GET'
  })
}
export function businessTableRemove(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/bus/businessTable/remove',
    method: 'POST',
    data: data
  })
}
export function businessTableRemoveEs(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/bus/businessTable/es',
    method: 'POST',
    data: data
  })
}
export function businessTableGet(id) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/bus/businessTable/get/' + id,
    method: 'GET'
  })
}
export function synchronizationBusinessTable(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/bus/businessTable/synchronization',
    method: 'POST',
    responseType: 'blob',
    data: JSON.stringify(data)
  })
}
export function synchronizationForm(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/design/synchronization',
    method: 'POST',
    responseType: 'blob',
    data: JSON.stringify(data)
  })
}
export function synchronizationBusinessObject(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/bus/businessObject/synchronization',
    method: 'POST',
    responseType: 'blob',
    data: JSON.stringify(data)
  })
}
export function businessObjectGet(id) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/bus/businessObject/get/' + id,
    method: 'GET'
  })
}
export function businessTableCreate(id) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/bus/businessTable/createTable/' + id,
    method: 'GET'
  })
}
export function businessTableColumnDelete(id) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/bus/businessTable/column/delete/' + id,
    method: 'GET'
  })
}
export function businessTableColumnMetadataInfo(id) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/bus/businessTable/metadataInfo',
    method: 'GET'
  })
}
export function businessTableColumnMetadataInfoByTableName(tableName) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/bus/businessTable/metadataInfo/' + tableName,
    method: 'GET'
  })
}
export function businessObjectGetStruct(id) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/bus/businessObject/getStruct/' + id,
    method: 'GET'
  })
}
export function getStruct(id) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/bus/render/getStruct/' + id,
    method: 'GET'
  })
}

export function businessObjectList(data) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/form/bus/businessObject/listJson/',
    method: 'POST',
    data: qs.stringify(data)
  })
}
export function designSave(data) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/form/design/json/save',
    method: 'POST',
    data: qs.stringify(data)
  })
}

/**
 * 对话框查询
 * @param data
 */
export function customDialogList(data) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/form/customDialog/listJson',
    method: 'POST',
    data: qs.stringify(data)
  })
}


/**
 * 保存对话框
 * @param data
 */
export function customDialogSave(data) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/form/customDialog/save',
    method: 'POST',
    data: qs.stringify(data)
  })
}
export function customDialogMetadataInfo(data) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/form/customDialog/metadataInfo/' + data,
    method: 'GET'
  })
}
export function businessTableMetadataInfo(data) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/form/bus/businessTable/metadataInfo/' + data,
    method: 'GET'
  })
}
export function customDialogGet(data) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/form/customDialog/get/' + data,
    method: 'GET'
  })
}
export function removeCustomDialog(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/customDialog/remove',
    method: 'POST',
    data: data
  })
}
export function removeCustomDialogEs(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/customDialog/es',
    method: 'POST',
    data: data
  })
}

export function updateFormModel(data) {
  return request({
    headers: {
      'Content-Type': 'application/json'
    },
    url: '/form/design/json/update/'+data.formKey,
    method: 'POST',
    data: data
  })
}
export function getFormModelVersion(formKey) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/form/design/version/get/'+formKey,
    method: 'POST',
  })
}

export function synchronizationDialog(data) {
  return request({

    url: '/form/customDialog/synchronization',
    method: 'POST',
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/json'
    },
    data: JSON.stringify(data)
  })

}
// 删除外挂URL单
export function delDesignByCodes(id) {

  return request({
    url: '/form/design/removeByCodes/' + id,
    method: 'GET'
  })
}
export function delDesignByCodesEs(id) {

  return request({
    url: '/form/design/es/' + id,
    method: 'GET'
  })
}
export function objJsonByFormKey(formKey) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/form/bus/businessObject/objJson/'+formKey,
    method: 'GET',
  })
}
export function condition(formKey) {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    url: '/a1bpmn/api/condition/'+formKey,
    method: 'GET',
  })
}




